#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
//#pragma warning(disable:4996)
int main058(void){
    int* ptr;
    int n;
    printf("请输入要分配的整数个数:\n");
    scanf("%d",&n);

    //使用malloc分配内存
    ptr = (int*)malloc(n* sizeof(int));
    if(ptr == NULL){
        printf("内存分配失败\n");
        return -1;
    }

    //初始化数组
    for (int j = 0; j < n; ++j) {
        ptr[j] = j+1;
    }

    //输出数组元素
    printf("输出数组结果：\n");
    for (int j = 0; j < n; ++j) {
        printf("%d ",ptr[j]);
    }
    printf("\n");

    //释放内存
    free(ptr);
    return 0;
}